<include file="Public/newset-header" title="修改邮箱" />
<link rel="stylesheet" href="__STATIC__/css/add.css">
<link rel="stylesheet" href="__STATIC__/css/cropper.min.css">
<link rel="stylesheet" href="__STATIC__/css/sitelogo.css">
<style type="text/css">
    .avatar-btns button {
        height: 35px;
    }
    
</style>
<div class="container" style="padding-bottom:40px;">
        <ul class="breadcrumb">
                <li><a href="{:U('Index/index')}">首页</a></li>
                <li class="active">基本信息</li>

        </ul>
    <div class="row">
            <include file="Public/newset-sidebar" title="侧边栏" />
    <div class="col-md-9">
        <div class="headline">
            <h1>修改邮箱</h1>
        </div>
        <form method="post" action="{:U('member/amendEmail')}">
        <div class="message">
            <div class="messages-inner">
            <section>
                <label>当前绑定邮箱 : {$model.username}</label>
            </section>
            <section>
                    <label>当前密码 <span>*</span></label>
                    <label class="text-input">
                        <input class="form-control" type="password" name="password" value="">
                        <i class="fa fa-key"></i>
                    </label>
            </section>
            <section>
                    <label>绑定邮箱<span>*</span></label>
                    <label class="text-input">
                        <input class="form-control" type="text" name="username" value="">
                        <i class="fa fa-envelope-o"></i>
                    </label>
            </section>
            </div>
            <hr>
            <div class="message-footer">
                <input type="hidden" name="id" value="{$model.id}">
                <button class="btn btn-success" type="submit" >确认修改</button>
            </div>
        </div>
        </form>
    </div>
</div>
</div>
<include file="Public/newset-footer" />
<script src="__STATIC__/js/cropper.js"></script>
<script src="__STATIC__/js/sitelogo.js"></script>
<script src="__STATIC__/js/html2canvas.min.js"></script>
<script type="text/javascript">
    //做个下简易的验证  大小 格式 
        $('#avatarInput').on('change', function(e) {
            var filemaxsize = 1024 * 5;//5M
            var target = $(e.target);
            var Size = target[0].files[0].size / 1024;
            if(Size > filemaxsize) {
                alert('图片过大，请重新选择!');
                $(".avatar-wrapper").childre().remove;
                return false;
            }
            if(!this.files[0].type.match(/image.*/)) {
                alert('请选择正确的图片!')
            } else {
                var filename = document.querySelector("#avatar-name");
                var texts = document.querySelector("#avatarInput").value;
                var teststr = texts; //你这里的路径写错了
                testend = teststr.match(/[^\\]+\.[^\(]+/i); //直接完整文件名的
                filename.innerHTML = testend;
            }        
        });
        $(".avatar-save").on("click", function() {
            var img_lg = document.getElementById('imageHead');
            // 截图小的显示框内的内容
            html2canvas(img_lg, {
                allowTaint: true,
                taintTest: false,
                onrendered: function(canvas) {
                    canvas.id = "mycanvas";
                    //生成base64图片数据
                    var dataUrl = canvas.toDataURL("image/jpeg");
                    var newImg = document.createElement("img");
                    newImg.src = dataUrl;
                    imagesAjax(dataUrl)
                }
            });
        })
        
        function imagesAjax(src) {
            var data = {};
            data.img = src;
            data.jid = $('#jid').val();
            $.ajax({
                url: "upload-logo.php",
                data: data,
                type: "POST",
                dataType: 'json',
                success: function(re) {
                    if(re.status == '1') {
                        $('.user_pic img').attr('src',src );
                    }
                }
            });
        }
    </script>



